package com.smartfast4j.springboot.mybatis.demo.service.impl;

import com.smartfast4j.springboot.mybatis.demo.dao.LearnResourceMapper;
import com.smartfast4j.springboot.mybatis.demo.pojo.LearnResource;
import com.smartfast4j.springboot.mybatis.demo.pojo.LearnResourceExample;
import com.smartfast4j.springboot.mybatis.demo.service.LearnResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LearnResourceServiceImpl implements LearnResourceService {

    @Autowired
    private LearnResourceMapper learnResourceMapper;

    @Override
    public int add(LearnResource learnResource) {
        return learnResourceMapper.insertSelective(learnResource);
    }

    @Override
    public int update(LearnResource learnResource) {
        return learnResourceMapper.updateByPrimaryKeySelective(learnResource);
    }

    @Override
    public int deleteById(Long id) {
        return learnResourceMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteByIds(List<Long> ids) {
        LearnResourceExample example = new LearnResourceExample();
        example.createCriteria().andIdIn(ids);
        return learnResourceMapper.deleteByExample(example);
    }

    @Override
    public LearnResource queryLearnResourceById(Long id) {
        return learnResourceMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<LearnResource> selectByExample(LearnResourceExample example) {
        return learnResourceMapper.selectByExample(example);
    }
}
